home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Guides / PicsData / Rexx / PZ_MakePic_Color.rexx < prev    next >
OS/2 REXX Batch file  |  1995-07-05  |  3KB  |  179 lines

  1. /*
  2. **  $VER: $Id: PZ_MakePic_Color.rexx,v 5.0 1993/11/12 01:14:23 chris Exp $
  3. **  Copyright (C) 1992, 1993 by Christian A. Weber, Zürich, Switzerland.
  4. **  REXX script internally used by PicZoo. Do not start manually.
  5. **
  6. **  You may wish to change MAXMEM for ADPro if you don't have enough RAM,
  7. **  and the delay after loading if you have a slow HD :)
  8. */
  9.  
  10. options results
  11. arg adprodir filename maxwidth maxheight maxdepth
  12. address 'ADPro'
  13.  
  14.  
  15. /*
  16. ** Make sure ADPro is running
  17. */
  18. IF ~show(ports,'ADPro') THEN
  19. DO
  20.     Address COMMAND 'C:Assign ADPRO: '||adprodir
  21.     Address COMMAND 'Run >NIL: ADPRO:ADPro MAXMEM=5000000 BEHIND'
  22.     Address COMMAND 'C:Wait 5'
  23.     IF ~show(ports,'ADPro') THEN EXIT
  24. END
  25.  
  26.  
  27. /*
  28. ** Screen types for ADPro
  29. */
  30. LORES        = 0
  31. HIRES        = 1
  32. LACE        = 2
  33. PAL        = 4
  34. XOVERSCAN    = 8
  35. YOVERSCAN    = 16
  36.  
  37. HIRESBIT    = 0
  38. LACEBIT        = 1
  39.  
  40.  
  41. /*
  42. ** Now load the picture ...
  43. */
  44. SCREEN_TYPE    LORES
  45. LFORMAT        'UNIVERSAL'
  46. LOAD        filename
  47.  
  48. IF RC == 0 THEN DO
  49.  
  50.     /*
  51.     ** Get the picture size
  52.     */
  53.     XSIZE
  54.     origwidth  = ADPRO_RESULT
  55.     YSIZE
  56.     origheight = ADPRO_RESULT
  57.  
  58.  
  59.     /*
  60.     **  Make a text string of the picture mode and size, and store it
  61.     **  in an environment variable
  62.     */
  63.     IMAGE_TYPE
  64.     type = WORD(ADPRO_RESULT,1)
  65.     if type = "GRAY" THEN DO
  66.         type = "G (" || origwidth || "x" || origheight || ")"
  67.     END
  68.     ELSE DO
  69.         type = "C (" || origwidth || "x" || origheight || ")"
  70.     END
  71.     Address COMMAND SetEnv PICZOO_IMAGETYPE type
  72.  
  73.  
  74.     /*
  75.     ** If we have an interlaced lo-res or a non-interlaced hi-res
  76.     ** picture, we must correct the aspect ratio accordingly.
  77.     ** We do this by changing orgwidth or orgheight.
  78.     */
  79.     SCREEN_TYPE
  80.     viewmode = ADPRO_RESULT
  81.  
  82.     IF BITTST(viewmode, HIRESBIT) THEN DO
  83.         origwidth = origwidth / 2
  84.         Say 'Hi-Res.'
  85.     END
  86.  
  87.     IF BITTST(viewmode, LACEBIT) THEN DO
  88.         origheight = origheight / 2
  89.         Say 'Interlaced.'
  90.     END
  91.  
  92.     IF origwidth > origheight THEN DO
  93.         width  = maxwidth
  94.         height = (origheight * maxwidth) / origwidth
  95.     END
  96.     ELSE DO
  97.         width  = (origwidth * maxheight) / origheight
  98.         height = maxheight
  99.     END
  100.  
  101.  
  102.     /*
  103.     ** Set the palette to match the PicZoo screen
  104.     */
  105.     POFFSET        0
  106.     PTOTAL        16
  107.     PUSED        16
  108.     PPOKE         0 170 170 170
  109.     PPOKE         1   0   0   0
  110.     PPOKE         2 255 255 255
  111.     PPOKE         3 255   0 255
  112.     PPOKE         4  34  34  34
  113.     PPOKE         5  51  51  51
  114.     PPOKE         6  68  68  68
  115.     PPOKE         7  85  85  85
  116.     PPOKE         8 102 102 102
  117.     PPOKE         9 119 119 119
  118.     PPOKE        10 136 136 136
  119.     PPOKE        11 153 153 153
  120.     PPOKE        12 187 187 187
  121.     PPOKE        13 204 204 204
  122.     PPOKE        14 221 221 221
  123.     PPOKE        15 238 238 238
  124.     PSTATUS        LOCKED
  125.  
  126.  
  127.     /*
  128.     **  Now set the parameters for the screenmode depending on the
  129.     **  picture's type (GRAY or COLOR).
  130.     **  Gray pictures will have 16 gray levels, color pictures will
  131.     **  be in HiRes-HAM6 (4096 colors).
  132.     */
  133.     IMAGE_TYPE
  134.     IF WORD(ADPRO_RESULT,1) = "GRAY" THEN DO
  135.         RENDER_TYPE    16
  136.     END
  137.     ELSE DO
  138.         PTOTAL        HAM
  139.         RENDER_TYPE    HAM
  140.     END
  141.  
  142. /*    RENDER_TYPE    2 */
  143. /*    PTOTAL        2 */
  144.  
  145.     /*
  146.     ** Make sure we get the best dynamic range
  147.     */
  148.     OPERATOR    DYNAMIC_RANGE 0 255
  149.  
  150.  
  151.     /*
  152.     ** Now we scale the image to width/height
  153.     */
  154.     ABS_SCALE    width height
  155.  
  156.  
  157.     /*
  158.     ** Render the image without any dithering
  159.     */
  160.     DITHER        0        /* (1=Floyd-Steinberg) */
  161.     SCREEN_TYPE    LORES
  162.     EXECUTE
  163.  
  164.  
  165.     /*
  166.     ** Now save the image as a temp file, where PicZoo can get it.
  167.     */
  168.     SFORMAT        'IFF'
  169.     SAVE        'T:__PicZooTmp.iff' 'IMAGE'
  170.  
  171. END
  172. ELSE DO
  173.     /*
  174.     ** LOAD returned an error
  175.     */
  176.     say filename || ': not a picture'
  177. END
  178.  
  179.